package com.mj.Map;


import com.mj.HashMap.Person;
import com.mj.file.FileInfo;
import com.mj.file.Files;

import java.util.HashMap;


/**
 * @Author: LDeng
 * @Date: 2021-03-10 17:33
 */
public class Main {

    static void test1(){
        Map<String,Integer> map=new TreeMap<>();
        map.put("c",2);
        map.put("a",5);
        map.put("b",6);
        map.put("a",8);

        map.traversal(new Map.Visitor<String, Integer>() {
            @Override
            public boolean visit(String key, Integer value) {
                System.out.println(key+"_"+value);
                return false;
            }
        });
    }

    static void test2(){
        FileInfo fileInfo = Files.read("C:\\Users\\LDeng\\Desktop\\src\\java\\util\\concurrent",
                new String[]{"java"});
        System.out.println("文件数量："+fileInfo.getFiles());
        System.out.println("文件行数："+fileInfo.getLines());
        String[] words=fileInfo.words();
        System.out.println("总共包含单词数："+words.length);

        Map<String,Integer> map=new TreeMap<>();
        for (int i = 0; i < words.length; i++) {
            Integer count = map.get(words[i]);
            count=(count==null)?1:count+1;
            map.put(words[i],count);
        }
        System.out.println(map.size());

        map.traversal(new Map.Visitor<String, Integer>() {
            @Override
            public boolean visit(String key, Integer value) {
                System.out.println(key+"_"+value);
                return false;
            }
        });
    }

    static void test3(){
        Set<String> set=new TreeSet2<>();
        set.add("c");
        set.add("a");
        set.add("b");
        set.add("a");

        set.traversal(new Set.Visitor<String>() {
            @Override
            boolean visit(String element) {
                System.out.println(element);
                return false;
            }
        });

    }

    public static void main(String[] args) {
        //test1();
       // test2();
       // test3();
        Person person=new Person(1,1.0f,"jack");
        Person person2=new Person(1,1.0f,"jack");

        System.out.println(person.hashCode());
        System.out.println(person2.hashCode());

        java.util.Map<Object,Object> map=new HashMap<>();
        map.put(person,"abc");
        //map.put("test","ccc");
        map.put(person2,"def");
        System.out.println(map.size());
        System.out.println(person.equals(person2));
        System.out.println(map.get(person));
        System.out.println(map.get(person2));
        System.out.println(131%128);
        System.out.println(131&127);
    }
}
